-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GCC: unused warnings #8359
GCC: unused warnings #8359
Conversation
src/wallet/wallet2.cpp
Outdated
@@ -5127,7 +5124,6 @@ std::string wallet2::exchange_multisig_keys(const epee::wipeable_string &passwor | |||
expanded_msgs.emplace_back(msg); | |||
|
|||
// reconstruct multisig account | |||
crypto::public_key dummy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is already fixed in one of the multisig PRs. Can you undo this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup
b1710f6
to
50a9879
Compare
src/wallet/wallet2.cpp
Outdated
@@ -3476,7 +3475,6 @@ void wallet2::refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blo | |||
if (!first && blocks.empty()) | |||
{ | |||
m_node_rpc_proxy.set_height(m_blockchain.size()); | |||
refreshed = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was set by the author to facilitate easier debugging, since with this variable in place, it appears in the locals
debugging window.
I personally don't need it, but just saying that this is the reason why I haven't removed it myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my thought as well. I don't see any need to remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a leftover from this patch: #6097 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hyc pushed changes to keep the flag in and remove the warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeffro256 "Easier debugging" was speculation. As it says in mooo's comment, he wanted to clean it up but probably forgot about it. We can ask him again to be sure but just silencing doesn't make much sense here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pinging @moneromooo-monero
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
12:34 <moneromooo> I had to reorder some code to fix... a timing info leak IIRC. In turn, this undid something I had fixed before, which I believe was a subtle race condition with the txpool.
12:35 <moneromooo> It was pretty subtle IIRC, and so I needed time to think about how to refix it after the move, and I never got to it. I do not remember the details of the race.
12:35 <moneromooo> I don't think I'm likely to ever get to it now.
12:43 <+selsta> ok ty, i guess i'll let the other decide if we keep the unused variable
12:45 <moneromooo> At this point, since it was to remind me, it could be replaced by a comment if people really hate it.
So either we remove the unused variable and add a comment or we keep it. Silencing doesn't make sense in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for commenting out rather than silencing.
There will surely be a lot of debugging to do there in future, but then it can be uncommented on demand, still not causing warnings to everybody else and not having to resort to compiler hacks, which might not be cross-platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should add some of mooo's commentary as a comment in the source too. Saves digging thru github issues to find out what it's all about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good, but please gather 2nd or even 3rd opinion about the wallet2
change.
src/crypto/hash-extra-jh.c
Outdated
@@ -38,5 +38,6 @@ | |||
|
|||
void hash_extra_jh(const void *data, size_t length, char *hash) { | |||
int r = jh_hash(HASH_SIZE * 8, data, 8 * length, (uint8_t*)hash); | |||
(void) r; // silence -Wunused-variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before anybody mentions inconsistency of the casting style:
This is C, not C++, so static_cast<>
can't be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So these are only unused because assert() is being no-op'd. These hash functions don't allocate memory so have no reason to fail. Maybe we can just get rid of r
and the asserts too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah since hashbitlen
is a compile-time constant, there should be no reason for jh_hash
to not return SUCCESS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay changes are pushed for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, sorry for the wishy-washiness but I'm gonna take back what I said and go with your initial patch. Safer to leave the asserts in place so that they're present in Debug builds, and will catch any accidental misuses of the code in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I make the assert
statements conditional on whether NDEBUG
is defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert() is already a #define that is empty when NDEBUG is defined. Do you mean conditionalizing the other statements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if NDEBUG
is defined, then don't check for error, otherwise do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, there's really no point checking for an non-success status since the only possible failure condition is if hashbitlen
is wrong. Since it's a compile-time constant in our case the only way someone could use it wrong is if they modified the hash-extra function bodies. I put a comment above that line in this PR which explains why we are not checking for a failure result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sounds good.
cc85eb4
to
82207fd
Compare
82207fd
to
faa1be6
Compare
src/wallet/wallet2.cpp
Outdated
// moneromooo-monero says this about the "refreshed" variable: | ||
// "I had to reorder some code to fix... a timing info leak IIRC. In turn, this undid something I had fixed before, ... a subtle race condition with the txpool. | ||
// It was pretty subtle IIRC, and so I needed time to think about how to refix it after the move, and I never got to it." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// moneromooo-monero says this about the "refreshed" variable: | |
// "I had to reorder some code to fix... a timing info leak IIRC. In turn, this undid something I had fixed before, ... a subtle race condition with the txpool. | |
// It was pretty subtle IIRC, and so I needed time to think about how to refix it after the move, and I never got to it." | |
// TODO: moneromooo-monero says this about the "refreshed" variable: | |
// "I had to reorder some code to fix... a timing info leak IIRC. In turn, this undid something I had fixed before, ... a subtle race condition with the txpool. | |
// It was pretty subtle IIRC, and so I needed time to think about how to refix it after the move, and I never got to it." | |
// https://github.com/monero-project/monero/pull/6097 |
TODO
so that it can be quickly found via git grep
. Also adding a URL for context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
faa1be6
to
1fc5de3
Compare
At this point I'm unlikely to spend a lot of time thinking about it and fixing it well. So if people want to kill the warning, be my guest. I'd be better if people wanted to fix it properly instead of just killing the warning, but that's up to them. |
@jeffro256 Can you keep the Sorry for this huge discussion :) |
hash_extra: don't test for success in `jh_hash` and `skein_hash` since its guaranteed device_ledger: move anonymous global variable apdu_verbose into .cpp file Add comments to `refreshed` method variable in wallet2
1fc5de3
to
4d7f6f5
Compare
@selsta done! |
This PR fixes 4 instances of
-Wunused...